#include <iostream>
#include <fstream>

using namespace std;

struct Book{
    char c[5];
    char n[11];
    int p;
    int q;
};

int main()
{
    Book a;
    ifstream inf("book.dat");
    ios_base::openmode m=ios_base::in|ios_base::out;
    fstream iof("out.dat",m|ios_base::trunc|ios_base::binary);

    if(inf.fail()||iof.fail()) return-1;
    while(!inf.eof())
    {
        inf>>a.c>>a.n>>a.p>>a.q;
        iof.write((char* )&a,sizeof(Book));
    }

    inf.close();
    iof.seekg(1* sizeof(Book),ios_base::beg);
    iof.read((char* )&a,sizeof(Book));
    iof.seekg(1*sizeof(Book),ios_base::end);
    iof.write((char*)&a,sizeof(Book));
    iof.close();
    return 0;
}





